package com.lkm.app_ui.m.Imple.sz_dataup;

import com.lkm.app_ui.AppConst;
import com.lkm.app_ui.help.GsonHelp;
import com.lkm.frame.task2.TaskAdapter;
import com.lkm.javatool.JsonP1;
import com.lkm.market2_0.entity.SteelyardInfo;
import com.lkm.market2_0.m.dataUp.SZCalibrationInfo;
import com.lkm.market2_0.m_imple.newDataUp.NewDataUpParse;
import com.lkm.market2_0.m_imple.newDataUp.NewSZApi;
import com.lkm.market2_0.m.steelyarddata.OrderEntity;
import com.lkm.market2_0.m.steelyarddata.SteelyardValue;
import com.lkm.market2_0.task.DefaultTaskExecutor;



public class SZCalibrationInfoTask extends TaskAdapter<Void, Object[], String> {
    SteelyardInfo steelyardInfo;
    SteelyardValue steelyardValue;
    OrderEntity.GoodEntity goodEntity;

    public SZCalibrationInfoTask(SteelyardInfo steelyardInfo, SteelyardValue steelyardValue, OrderEntity.GoodEntity goodEntity) {
        super(new DefaultTaskExecutor(true), SZCalibrationInfoTask.class.getName(), AppConst.getTaskManager2());
        this.steelyardInfo = steelyardInfo;
        this.steelyardValue = steelyardValue;
        this.goodEntity = goodEntity;
    }

    @Override
    public void doExecuting(Void param) {
        super.doExecuting(param);
        mTaskExecutor.executorDoAsyncExecuting(new Runnable() {
            @Override
            public void run() {



                String error = "";
                try {



//                    float js = ((goodEntity.ad - goodEntity.offsetZeroAD) * 10000) / (float)goodEntity.kValue;







                    SZCalibrationInfo szWeightInfo = NewDataUpParse.parseSZCalibrationInfo(steelyardInfo, steelyardValue, goodEntity);


                    String json = NewSZApi.calibrationInfo(szWeightInfo, SZCalibrationInfoTask.this, true);

                    JsonP1 jsonP1 = new JsonP1(GsonHelp.toJsonTree(json));

                    if (jsonP1.get("result",true).get("success",false).getAsBoolean(false)) {
                        error = "";
                    }else {
                        error = json;
                    }
                } finally {
                    complete(error);
                }


            }
        });
    }
}
